package com.banquetmanagementsystem.mapper;

import com.banquetmanagementsystem.pojo.entity.Wallet;
import org.apache.ibatis.annotations.*;

/**
 * @author 86176
 */
@Mapper
public interface WalletMapper {
    /**
     * 开通钱包
     * @param userId 用户id
     * @return 受影响条数
     */
    @Insert("INSERT INTO  wallet(user_id,password,balance) VALUES(#{userId},#{password},0.00)")
    Integer insertWallet(String userId,String password);

    /**
     * 根据用户id关闭钱包
     * @param userId 用户id
     * @return 受影响条数
     */
    @Delete("DELETE FROM wallet WHERE user_id = #{userId}")
    Integer deleteWalletByUserId(String userId);

    /**
     *  修改钱包密码
     * @param userId 用户id
     * @param password 支付密码
     * @return 受影响条数
     */
    @Update("UPDATE wallet SET password = #{password} WHERE user_id = #{userId}")
    Integer updateWalletPassword(String userId,String password);

    /**
     * 根据用户id更新余额
     * @param userId 用户id
     * @param balance 余额
     * @return 受影响条数
     */
    @Update("UPDATE  wallet SET balance = #{balance} WHERE user_id = #{userId}")
    Integer updateWalletBalance(String userId,String balance);

    /**
     * 根据用户id查询钱包
     * @param userId 用户id
     * @return 钱包
     */
    @Select("SELECT * FROM wallet WHERE user_id = #{userId}")
    Wallet selectWalletByUserId(String userId);
}
